#!/usr/bin/python
import struct

def float_to_bin(fd, f):
	bytes = struct.pack('>f', f)
	fd.write(bytes)

def int_to_bin(fd, i):
	bytes = struct.pack('>i', i)
	fd.write(bytes)

def byte_to_bin(fd, b):
	bytes = struct.pack('>b', b)
	fd.write(bytes)

def string_to_bin(fd, s, size):
	bytes = bstr(s,size)
	fd.write(bytes)

def bstr(s, size):
	return struct.pack('>' + str(size) + 's', s)


#def write_binary_file(fd, array):
#	if type(element) == int:
#		int_to_bin(fd, element)
#	elif type(element) == float:
#		float_to_bin(fd, element)
#	elif type(element) == string:
#		string_to_bin(fd, element, 32)
